Page({

  /**
   * 页面的初始数据
   */
  data: {

    zanCurSelected: 0,
    info: [{
        zanNum: 0,
        commentsNum: 11,
        shareNum: 14,
        zanSelect: false,
        focusSelect: false
      },
      {
        zanNum: 12,
        commentsNum: 23,
        shareNum: 11,
        zanSelect: false,
        focusSelect: false
      },
      {
        zanNum: 24,
        commentsNum: 32,
        shareNum: 5,
        zanSelect: false,
        focusSelect: false
      },

    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function(options) {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  },
  //   发布按钮
  release: function() {
    wx.navigateTo({
      url: '../release-found/release-found' // 指定页面的url
    });
  },
  toDetail: function() {
    wx.navigateTo({
      url: "../found-detail/found-detail"
    })
  },
  // 点赞
  zanSelect: function(e) {
    var index = e.currentTarget.dataset.index;
    var info = this.data.info;
    for (var i = 0; i < info.length; i++) {
      if (index == i) {
        info[i].zanSelect = !info[i].zanSelect;
        if (info[i].zanSelect) {
          info[i].zanNum++;
        } else {
          info[i].zanNum--;
        }
      }
    }
    this.setData({
      info: info,
      zanCurSelected: index
    })
  },
  // 关注
  focus: function(e) {
    var index = e.currentTarget.dataset.index;
    var info = this.data.info;
    for (var i = 0; i < info.length; i++) {
      if (index == i) {
        info[i].focusSelect = !info[i].focusSelect;
      }
    }
    this.setData({
      info: info,
      zanCurSelected: index
    })
  }
})